package org.summer.generator.writer.impl;

import org.summer.generator.log.Logger;
import org.summer.generator.log.LoggerManager;
import org.summer.generator.vo.MethodInfo;
import org.summer.generator.writer.AbstractJavaFileWriter;

/**
 * mybatis Mapper映射接口文件写入处理类
 */
public class MapperFileWriter extends AbstractJavaFileWriter {
    private static final Logger log = LoggerManager.getLogger(MapperFileWriter.class);
    @Override
    public void execute() {
        String packageName = project.getMapperPackageName();
        String classDefinition = getInterfaceDefinition(packageName,writer.getMapperParentInterface());
        channel.writerNewline(getPackageDefinition(packageName));
        channel.writerEmptyLine();
        channel.writerNewline(table.getEntityImportStr());
        importSet.forEach(channel::writerNewline);
        channel.writerNewline("import org.apache.ibatis.annotations.Mapper;");
        channel.writerEmptyLine();
        channel.writerNewline(CLASS_REMARK.formatted(table.getRemark() + ",mybatis 映射处理接口"));
        channel.writerNewline("@Mapper");
        channel.writer(classDefinition);
        channel.writerEmptyLine();
        channel.writer(BLOCK_END);
    }

    @Override
    protected void writerMethod(MethodInfo method, String previousObject, String loadMethodName) {

    }
}
